<#include "/java_copyright.include">
<#assign className = table.className>   
<#assign classNameLower = className?uncap_first> 
package ${basepackage}.controller.impl;

import java.io.Serializable;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import com.shinsoft.service.${className}Service;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;

import com.shinsoft.controller.${className}Controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;






import com.shinsoft.pojo.${className};


@Controller
@RequestMapping(value = "/${classNameLower}")
public class ${className}ControllerImpl implements ${className}Controller{

	@Autowired
	private ${className}Service ${classNameLower}Service;
	
	private static final Logger LOGGER = LoggerFactory
			.getLogger(${className}ControllerImpl.class);
	
	@RequestMapping(method = RequestMethod.GET, value = "all")
	@Override
	public @ResponseBody List<${className}> get${className}s(){
		List<${className}> ${classNameLower}s;
		try{
			${classNameLower}s = ${classNameLower}Service.get${className}s();
		}catch(BussinessException e){
			throw e;
		}
		return ${classNameLower}s;
	}
	
	@RequestMapping(method = RequestMethod.GET)
	@Override
	public @ResponseBody ${className} getById(@RequestParam("id") Serializable id){
		${className} ${classNameLower};
		try{
			${classNameLower} = ${classNameLower}Service.getById(id);
		}catch(BussinessException e){
			throw e;
		}
		return ${classNameLower};
	}
	
	@RequestMapping(method = RequestMethod.DELETE)
	@Override
	public @ResponseBody void delete(@RequestParam("id") Serializable id){
		try{
			${classNameLower}Service.delete(id);
		}catch(BussinessException e){
			throw e;
		}
	}
	
	@RequestMapping(method = RequestMethod.PUT)
	@Override
	public void update(${className} ${classNameLower}){
		try{
			${classNameLower}Service.update(${classNameLower});
		}catch(BussinessException e){
			throw e;
		}
	}
	
	@RequestMapping(method = RequestMethod.POST)
	@Override
	public void save(${className} ${classNameLower}){
		try{
			${classNameLower}Service.save(${classNameLower});
		}catch(BussinessException e){
			throw e;
		}
	}
	
	@Override
	public void batchSave(List<${className}> ${classNameLower}s){
		try{
			${classNameLower}Service.batchSave(${classNameLower}s);
		}catch(BussinessException e){
			throw e;
		}
	}
	
}
